package com.hngy;

import com.hngy.domain.Employee;
import com.hngy.service.EmployeeService;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.List;

/**
 * @author LiKe
 * @date 2021/12/26 18:20
 */
@SpringBootTest
public class EmployeeApplication {
    @Autowired
    public EmployeeService employeeService;
    @Test
    public void page(){
        List<Employee> employeeList = employeeService.myPage(0, 5,"张%");

        System.out.println(employeeList);
    }

    @Test
    public void excel() throws Exception {
        //创建HSSFWorkbook对象
        HSSFWorkbook wkb = new HSSFWorkbook();
        //创建HSSFSheet对象
        HSSFSheet sheet = wkb.createSheet("sheet0");
        //创建HSSFRow对象
        HSSFRow row = sheet.createRow(1);
        //创建HSSFCell对象
        HSSFCell cell=row.createCell(2);
        //设置单元格的值
        cell.setCellValue("单元格中的中文4");
        //输出Excel文件
        FileOutputStream output=new FileOutputStream("d:\\workbook.xls");
        wkb.write(output);
        output.flush();
    }
}
